﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using ORS.BLL;

namespace ORS.Web
{
    public partial class ManageUsers : System.Web.UI.Page
    {
        int i,scounts;
        static int  key = 0;
        string reg_user_ID;
        string[] user_ids;  
        DataTable dt;
        Getuserinformation ivk5_getuerinfo = new Getuserinformation();
        RegisterAudit ivk5_registeraudit = new RegisterAudit();
        DeleteUsers ivk5_deleteusers = new DeleteUsers();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.Session["Admim_IDS"] == null)
                Response.Redirect("Login.aspx");
            else
            {
                btn_auditreg.Enabled = false;
                btn_Delete.Enabled = false;
                lblaudit.Visible = false;
            }
        }

        protected void btn_Auditing_Click(object sender, EventArgs e)
        {
            dt = ivk5_getuerinfo.GetRegisteringUserInfo();
            GridView1.DataSource = dt;
            GridView1.DataBind();
            btn_auditreg.Enabled = true;
            btn_Delete.Enabled = true;
            lblaudit.Visible = true;
            lblaudit.Text = "未审核注册用户列表";
            key = 1;
        }

        protected void btn_auditreg_Click(object sender, EventArgs e)
        {
            user_ids = this.Request["register_audit"].Split(',');
            scounts = user_ids.Length;
            for (i = 0; i < scounts; i++)
            {
                reg_user_ID = user_ids[i].Trim();
                ivk5_registeraudit.CheckRegister(reg_user_ID);
            }
            dt = ivk5_getuerinfo.GetRegisteringUserInfo();
            GridView1.DataSource = dt;
            GridView1.DataBind();
            btn_auditreg.Enabled = true;
            btn_Delete.Enabled = true;
            lblaudit.Visible = true;
            lblaudit.Text = "未审核注册用户列表";
        }

        protected void btn_Browse_Click(object sender, EventArgs e)
        {
            dt = ivk5_getuerinfo.GetRegistedUserinfo();
            GridView1.DataSource = dt;
            GridView1.DataBind();
            btn_auditreg.Enabled = false;
            btn_Delete.Enabled = true;
            lblaudit.Visible = true;
            lblaudit.Text = "已审核注册用户列表";
            key = 2;
        }

        protected void btn_Delete_Click(object sender, EventArgs e)
        {
            user_ids = this.Request["register_audit"].Split(',');
            int scounts = user_ids.Length;
            for (i = 0; i < scounts; i++)
            {
                reg_user_ID = user_ids[i].Trim();
                ivk5_deleteusers.DeleteRecord(reg_user_ID);
            }
            switch  (key)
            { 
                case 1:
                    dt = ivk5_getuerinfo.GetRegisteringUserInfo();
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    btn_auditreg.Enabled = true;
                    btn_Delete.Enabled = true;
                    lblaudit.Visible = true;
                    lblaudit.Text = "未审核注册用户列表";
                    break;
                case 2:
                    dt = ivk5_getuerinfo.GetRegistedUserinfo();
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    btn_auditreg.Enabled = false;
                    btn_Delete.Enabled = true;
                    lblaudit.Visible = true;
                    lblaudit.Text = "已审核注册用户列表";
                    break;
                default:
                    break;

            } 

        }





    }
}


//            string[] paper_links = this.Request["paper_select"].Split(',');
     //       string link_url = paper_links[0].Trim();
   //         Response.Redirect(link_url);